package mygame.Model;

import java.util.HashMap;

import mygame.Manager;

import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.scene.Geometry; 
import com.jme3.scene.Node;
import com.jme3.scene.shape.Sphere;


public class PlanetManager {
	
	private AssetManager asm;
	
	private Node universe;
	private Planet activePlanet;
	private HashMap<String, Planet> planetMap;
	
	public PlanetManager(Node root, AssetManager asm){
		universe = new Node();
		root.attachChild(universe);
		this.asm = asm;
		
		planetMap = new HashMap<>();
	}
	
	public Planet generatePlanet(float size){
		Sphere b = new Sphere(32, 32, size, false, false);//new Sphere(32, 32, size);
    	//Quad b = new Quad(2, 2);
    	//Box b = new Box(Vector3f.ZERO, 10, 0.4f, 10);
        Geometry geom = new Geometry("BoxModel",b);
        geom.move(0, 1, 0);
        Material mat = new Material(asm, "Common/MatDefs/Light/Lighting.j3md");
        mat.setBoolean("UseMaterialColors", true);
        mat.setColor("Ambient",  ColorRGBA.Orange);
        mat.setColor("Diffuse",  ColorRGBA.Orange);
        mat.setColor("Specular", ColorRGBA.White);
        //mat.setFloat("Shininess", 12);
        mat.setTexture("DiffuseMap",asm.loadTexture("Textures/dirt.jpg"));
        //Material gMat = asm.loadMaterial("Materials/Ground.j3m");
        //gMat.getAdditionalRenderState().setWireframe(true);
        //mat.setReceivesShadows(true);

        geom.setMaterial(mat);
        geom.setShadowMode(ShadowMode.CastAndReceive);
        universe.attachChild(geom);
        
        activePlanet = new Planet(geom, size);
        return activePlanet;
	}
	
	public Node getUniverse(){
		return this.universe;
	}
	
}
